/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-12-12
 * Time: 下午2:47
 * To change this template use File | Settings | File Templates.
 */
Ext.define('Airways.view.system.userrole.UserRoleLeft',{
    extend:'Ext.grid.Panel',
    alias:'widget.userRoleLeft',
    store:'system.user.UserManageStore',
    layout:'fit',
    autoScroll:true,
    height:'100%',
    initComponent:function(){
        this.dockedItems = this.buildDockedItems();
        this.bbar = this.buildBbar();
        this.columns = this.buildColumns();
        this.callParent(arguments);
    },
    buildDockedItems:function(){
        return [{
            dock: 'top',
            xtype: 'toolbar',
            items:['-',{
                xtype:'label',
                text:'用户编号:'
            },{
                xtype:'textfield',
                name:'userNo'
            },'-',{
                xtype:'label',
                text:'用户名称:'
            },{
                xtype:'textfield',
                name:'userName'
            },'-',{
                xtype:'label',
                text:'状态:'
            },{
                xtype:'combo',
                name:'status',
                queryMode:'local',
                displayField:'value',
                valueField:'key',
                store:Ext.create('Ext.data.Store',{
                    model:'comboxModel',
                    data:[{key:'',value:'全部'},{key:'1',value:'启用'},{key:'0',value:'禁用'}]
                })
            },'-',{
                xtype:'button',
                iconCls:'search',
                text:'查询',
                action:'find'
            },'-']
        }];
    },
    buildBbar:function(){
        return Ext.create('Ext.PagingToolbar', {
            store:'system.user.UserManageStore',
            displayInfo: true
        });
    },
    buildColumns:function(){
        return [
            Ext.create('Ext.grid.RowNumberer'),
            {text:'用户编号',dataIndex:'userNo',width:150},
            {text:'用户名称',dataIndex:'userName',width:150},
            {text:'分部',dataIndex:'subsectionName',width:150},
            {text:'邮件',dataIndex:'userMail',width:200},
            {text:'用户状态',dataIndex:'status',renderer:this.changeStatus,flex:1}
        ];
    },
    changeStatus:function(val) {
        if (val == 0) return "禁用";
        if (val == 1) return "启用";
    }
})
